Steve makes torture, Test-all improvements. Let coastexp be more forgiving about...
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 9 Dec 2012 19:25:28 +0000 (19:25 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 9 Dec 2012 19:25:28 +0000 (19:25 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4220 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/Makefile.in
gpsbabel/coastexp.c
gpsbabel/test-all
gpsbabel/torture_test

index c452c18a8d4a07b78ea21069da9ef25a072a8fd2..6fc702208e2edd6cfc82c2d08de354f05ec19e6a 100644 (file)
@@ -138,6 +138,7 @@ fileinfo.o: win32/gpsbabel.rc
 clean:
        rm -f $(OBJS) gpsbabel gpsbabel.exe
        if [ -f gui/Makefile ]; then $(MAKE) -C gui clean; fi
+       ./test-all -W
 
 configure: configure.in
        autoconf
@@ -166,7 +167,7 @@ torture:
 #      faults, math overflows and other hard errors
 #
        @echo "test-all in progress... (read/write test between all possible formats)"
-       @./test-all -s -r reference/expertgps.gpx
+       @./test-all -s -r reference/expertgps.gpx -t
 
 #
 # This will only work on UNIX-like substances.
index 6ff0420df76ed64183677ca149576706e7cd01da..2af2150b5e00ec8128ff2132d5ab994475b9667e 100644 (file)
@@ -390,9 +390,11 @@ ce_check_route_names(void)
     ce_route* route = (ce_route*) elem;
     if (route->r->rte_name == NULL)    {
       *cdatastr = '\0';
-      strcat(cdatastr, ((ce_mark*) QUEUE_FIRST(&route->ce_mark_head))->wp->shortname);
-      strcat(cdatastr, "->");
-      strcat(cdatastr, ((ce_mark*) QUEUE_LAST(&route->ce_mark_head))->wp->shortname);
+      if (!QUEUE_EMPTY(&route->ce_mark_head)) {
+        strcat(cdatastr, ((ce_mark*) QUEUE_FIRST(&route->ce_mark_head))->wp->shortname);
+        strcat(cdatastr, "->");
+        strcat(cdatastr, ((ce_mark*) QUEUE_LAST(&route->ce_mark_head))->wp->shortname);
+      }
       route->r->rte_name = xstrdup(cdatastr);
     }
   }
index 58fb3e2425b03e8d3776486cd79edaec51d8495a..57ff14d8ce23444ab23a4d43688d03f0750bdd6f 100755 (executable)
@@ -7,13 +7,38 @@ REFGPX="reference/expertgps.gpx"      # reference file for all tests
 EXCL="exif ozi vitosmt xol navigonwpt gopal"   # exclude formats from test
 CAPS=""
 TEMPDIR=${GBTEMP:-/tmp}/gb-test-all
-CATALOG=/tmp/gb-test-all.done
-LOGFILE=/tmp/gb-test-all.log
-RNDFILE=/tmp/gb-random.gpx
+CATALOG=${GBTEMP:-/tmp}/gb-test-all.done
+LOGFILE=${GBTEMP:-/tmp}/gb-test-all.log
+RNDFILE=${GBTEMP:-/tmp}/gb-random.gpx
 
 # options
 vg=0
 prep=0
+tally=0
+judge=0
+
+function tally_log()
+{
+    local exceptions=`grep '^cmd([0-9]*)\*[*]*:' $LOGFILE | wc -l`
+    local onlyunexpected=`grep '^cmd([0-9]*)\*:' $LOGFILE | wc -l`
+    local nonfatals=`grep '^cmd([0-9]*)\*\*:' $LOGFILE | wc -l`
+    local fatals=`grep '^cmd([0-9]*)\*\*\*:' $LOGFILE | wc -l`
+    local totals=`grep '^cmd([0-9]*)[*]*:' $LOGFILE | wc -l`
+    echo "Fatal Error Cases:"
+    grep '^cmd([0-9]*)\*\*\*:' $LOGFILE
+    echo ""
+    echo Error Summary:
+    echo "tests with errors and/or unexpected output: $exceptions"
+    echo "  tests without error but with unexpected output: $onlyunexpected"
+    echo "  tests with non-fatal errors: $nonfatals"
+    echo "  tests with fatal errors: $fatals"
+    echo "total tests: $totals"
+    if [ $fatals -gt 0 ]; then
+        return 1
+    else
+        return 0
+    fi
+}
 
 function log_entry()
 {
@@ -27,25 +52,36 @@ function try_run() # command line
 {
     local CMD="$*"
     local RES=0
+    local SEVERITY=""
     
     [ $vg -ne 0 ] && CMD="valgrind -q $CMD"
 
     ${CMD} > $TEMPDIR/.result 2>&1
     RES=$?
     if [ $RES -ne 0 -o -s $TEMPDIR/.result ]; then
-       if [ $RES -ne 0 ]; then
-           echo " -- Uhps --"
-           echo "-----------------------------------------------------------------------"
-           test -s $TEMPDIR/.result && cat $TEMPDIR/.result
-           echo "-----------------------------------------------------------------------"
-       else
-           echo ""
-       fi
-       log_entry "cmd($RES): $CMD"
-       test -s $TEMPDIR/.result && cat $TEMPDIR/.result >> ${LOGFILE}
-       return 1
+        if [ $RES -ne 0 ]; then
+            echo " -- Signal $RES --"
+            if [ -s $TEMPDIR/.result ]; then
+                echo "---------------------------output-follows------------------------------"
+                cat $TEMPDIR/.result
+                echo "-----------------------------------------------------------------------"
+            fi
+        else
+            echo " -- unexpected output exists, see $LOGFILE --"
+        fi
+        if [ $RES -gt 128 ]; then
+            SEVERITY="***"
+        elif [ $RES -gt 0 ]; then
+            SEVERITY="**"
+        else
+            SEVERITY="*"
+        fi
+        log_entry "cmd($RES)$SEVERITY: $CMD"
+        test -s $TEMPDIR/.result && cat $TEMPDIR/.result >> ${LOGFILE}
+        return 1
     else
-       return 0
+        log_entry "cmd($RES): $CMD"
+        return 0
     fi
 }
 
@@ -59,54 +95,54 @@ function STAGE_1 () # type format
     
     while read type caps format comment; do
     
-       for i in $EXCL; do
-           if [ "$format" == "$i" ]; then
-               caps="------"
-           fi
-       done
-       
-       grep "$TYP: $FMT & $format" ${CATALOG} > /dev/null && continue
-       
-       echo -n "testing "
-       case $TYP in
-           w)
-               echo -n "waypoints"
-               caps=${caps:0:2}
-               ;;
-           t)
-               echo -n "tracks"
-               caps=${caps:2:2}
-               ;;
-           r)
-               echo -n "routes"
-               caps=${caps:4:2}
-               ;;
-       esac
+        for i in $EXCL; do
+            if [ "$format" == "$i" ]; then
+            caps="------"
+            fi
+        done
+        
+        grep "$TYP: $FMT & $format" ${CATALOG} > /dev/null && continue
+        
+        echo -n "testing "
+        case $TYP in
+            w)
+            echo -n "waypoints"
+            caps=${caps:0:2}
+            ;;
+            t)
+            echo -n "tracks"
+            caps=${caps:2:2}
+            ;;
+            r)
+            echo -n "routes"
+            caps=${caps:4:2}
+            ;;
+        esac
 
-       echo -n ": \"$FMT\" with \"$format\" "
-       
-       IFILE=$TEMPDIR/$TYP-$FMT
-       OFILE=$TEMPDIR/$TYP-$FMT.$format
-       
-       case $caps in
-           -w)
-               echo -n "*"
-               CMD1="${PNAME} -$TYP -i $FMT -f $IFILE -o $format -F $OFILE"
-               try_run "${CMD1}" || continue
-               ;;
-               
-           rw)
-               echo -n "*"
-               CMD1="${PNAME} -$TYP -i $FMT -f $IFILE -o $format -F $OFILE"
-               try_run "${CMD1}" || continue
-               echo -n "*"
-               CMD2="${PNAME} -$TYP -i $format -f $OFILE -o $FMT -F $OFILE.$FMT"
-               try_run "${CMD2}" || continue
-               ;;
-       esac
-       
-       echo "*"
-       echo "$TYP: $FMT & $format" >> $CATALOG
+        echo -n ": \"$FMT\" with \"$format\" "
+        
+        IFILE=$TEMPDIR/$TYP-$FMT
+        OFILE=$TEMPDIR/$TYP-$FMT.$format
+        
+        case $caps in
+            -w)
+            echo -n "*"
+            CMD1="${PNAME} -$TYP -i $FMT -f $IFILE -o $format -F $OFILE"
+            try_run "${CMD1}" || continue
+            ;;
+            
+            rw)
+            echo -n "*"
+            CMD1="${PNAME} -$TYP -i $FMT -f $IFILE -o $format -F $OFILE"
+            try_run "${CMD1}" || continue
+            echo -n "*"
+            CMD2="${PNAME} -$TYP -i $format -f $OFILE -o $FMT -F $OFILE.$FMT"
+            try_run "${CMD2}" || continue
+            ;;
+        esac
+        
+        echo "*"
+        echo "$TYP: $FMT & $format" >> $CATALOG
     done
     return 0
 }
@@ -116,7 +152,9 @@ function STAGE_0 ()
     echo "$CAPS" |
     
     while read type caps format comment; do
-    
+ if [ "$format" -ne "pocketfms_wpt" ]; then
+   continue;
+ fi   
        for i in $EXCL; do
                if [ "$format" == "$i" ]; then
                        caps="------"
@@ -202,7 +240,9 @@ if test ! -s $REFGPX; then
     exit 1
 fi
 
-test -s $LOGFILE && rm -f $LOGFILE.bak > /dev/null
+rm -rf $TEMPDIR > /dev/null
+mkdir -p $TEMPDIR > /dev/null
+rm -f $LOGFILE
 touch $LOGFILE
 touch $CATALOG
 
@@ -211,3 +251,11 @@ echo "Catalog: $CATALOG" >> $LOGFILE
 
 CAPS=`${PNAME} -^2 | grep "^file"`
 STAGE_0
+if [ $tally -ne 0 ]; then
+    tally_log
+    judgement=$?
+    if [ $judge -ne 0 ]; then
+        exit $judgement
+    fi
+fi
+exit 0
index 66095cf55f270a462d851f97f596858ad08139ae..a05f59f7782a3b86ac6b4fde1fe10fa8f916505d 100755 (executable)
@@ -1,8 +1,9 @@
+#!/bin/sh
 
 PNAME=${PNAME:-./gpsbabel}
 DIFF=${DIFF:-diff}
 
-TMPDIR=/tmp/gpsbabel.$$
+TMPDIR=${GBTEMP:-/tmp}/gpsbabel.$$
 mkdir -p $TMPDIR
 trap "rm -fr $TMPDIR" 0 1 2 3 15